/*
Script: nnyFeeWaiverTable

Purpose: This script creates a table about fee waiver usage among the NNY cohort
from 2017. It shows that people who receive help from providers are more likely to 
use the fee waiver.

Input: 
NNYFeeWaiverDataForReplication_anon 

Output: 
effectAssist.tex

Created by: Michael Hotard
Date created: March 20, 2019
Modified by: Jens Hainmueller, Michael Hotard
Date modified: 7/9/19

* variables needed to match the analysis from the ACS

Gender
Age
Age 2
Country of Origin
Education
Married
English Language
Years in US
Years in US squared
HHINC

Variables we don't have 
Race
Central City
Married to Citizen
Labor Force
Veteran
*/


*/                                                                                                

*** setting up the code
set more off
clear all



*** Set location of data and location for output

global data_location   = ""
global output_location = ""


* reading in the data file
use "$data_location/NNYFeeWaiverDataForReplication_anon", clear




* setting the output location
cd "$output_location"



* defining covariates for the model
global covars = "educ_HS educ_somecollege educ_BA gender_f plang_Eng yrs_greencard_Q yrs_greencard_Q_sq age_Q age_Q_sq i.hhinc_Q marital_married origin_DR origin_China origin_Ecuador"


 

/* Table: Used Fee Waiver for Naturalization
Model 1 regress the outcome of whether a person used the fee waiver when applying for naturalization. Model 1 includes variables for ///
whether or not the applicant received professional or non-professional assistance with their application. Model 2 includes covariates that model /// 
the covariate set used in the analysis of the ACS data. The data for this analysis comes from a follow-up survey of an experiment in New York City ///
measuring the effect of notifying immigrants about their fee waiver eligibility. */

eststo clear

* model 1
eststo: reg usefw  received_assistance_isp received_assistance_laywer_fee received_assistance_friend if submit == 1, robust  
estadd local covars "No"
estadd scalar adjustedr=e(r2_a)



* model 2
eststo: reg usefw  received_assistance_isp received_assistance_laywer_fee received_assistance_friend anyfeewaivernote $covars if submit == 1, robust 


estadd local covars "Yes"
estadd scalar adjustedr=e(r2_a)

esttab * using effectAssist.tex, varlabels(_cons Constant) label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Used Fee Waiver for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(N adjustedr,fmt(0 "" 3) label("Observations" "Adjusted \(R^{2}\)"))  ///
 title(Effect of Application Assistance \label{tab:natny}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{3}{p{5.2in}}{\scriptsize ///
 Notes: Regression coefficients shown with robust standard errors in parenthesis. ///
 Model 1 regresses the outcome of whether a person used the fee waiver when applying for naturalization on  ///
 whether or not the applicant received professional or non-professional assistance with their application. Model 2 includes covariates that model /// 
 the covariate set used in the analysis of the ACS data. The data for this analysis comes from a follow-up survey of an experiment in New York ///
 measuring the effect of notifying immigrants about their fee waiver eligibility.} ///
 \end{tabular} ///
 \end{table} ///
 )
 

* model 3
reg usefw received_assistance_prof received_assistance_friend anyfeewaivernote educ_HS educ_somecollege educ_BA gender_f plang_Eng i.yrs_greencard_Q i.age_Q i.hhinc_Q marital_married ///
 origin_DR origin_China origin_Ecuador if submit == 1, robust 


